<template>
	<div>
		<div class="Item" v-for="itemData in Goods">
			<image @click="ToGood(itemData.id)" class="itemImage" :src="itemData.images" ></image>
			<p class="itemContent">{{itemData.name}}</p>
			<p class="itemMoney">${{itemData.price}}</p>
		</div>
	</div>
</template>

<script>
	var Goods = null
	export default{
		name:'ClassIn',
		data(){
			return{
				Goods:Goods
			}
		},
		onLoad:function(){
			uni.request({
				url: "http://" + getApp().globalData.IpAddr + "/goods-type/" + getApp().globalData.NowTypeGoods,
				method:"GET",
				header:{	'authorization':getApp().globalData.token	},
				success:res=> {
					// console.log(res)
					if(!res.data.success)	wx.showToast({	title: '请求发送失败',	duration: 2000	})
					else{
						getApp().globalData.NowType = res.data.data
						this.Goods = getApp().globalData.NowType
					}
				}
			})
		},
		methods:{
			ToGood(id){
				getApp().globalData.goodsId = id;
				uni.request({
					url: "http://" + getApp().globalData.IpAddr + "/goods/" + getApp().globalData.goodsId,
					method:"GET",
					header:{	'authorization':getApp().globalData.token	},
					success:res=> {
						getApp().globalData.NowGood = res.data.data
						// console.log(res)
						if(res.data.success) uni.navigateTo({	url: "/pages/ext/commodity"	})
						else wx.showToast({	title: '请求发送失败',	duration: 2000	})
						}
				})
				
			}
	},
	}
</script>

<style>
	.Item{
		width: 40vw;
		height: 50vw;
		padding: 5vw;
		float: left;
	}
	.itemImage{
		width: 100%;
		height: 40vw;
	}
	.itemContent{
		text-align: center;
		max-width: 45vw;
		font-size: 10px;
		-webkit-line-clamp: 2;
	}
	.itemMoney{
		text-align: left;
		margin-top: 3vw;
	}
</style>